<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

namespace app\index\controller;

use app\common\lib\Util;

/**
 * Description of chart
 *
 * @author tang
 */
class Chart {
    //put your code here
    public function push() {
        //入库
        //推送
        $data = [
            'name' => 'user'.mt_rand(100, 999),
            'text' => $_POST['data']
        ];
        foreach( $_POST['http_server']->ports[1]->connections as $fd)
        {
            $_POST['http_server']->push($fd,json_encode($data));
        }
        
        Util::show(config('code.success'), '发送成功');
    }
}
